package com.parenting.controller;


import com.parenting.oauth2.config.AuthUtil;
import com.parenting.request.wechat.WechatRecordRequest;
import com.parenting.response.wechat.CouponUsageRecord;
import com.parenting.response.wechat.WechatDateRecordResponse;
import com.parenting.service.CouponUsageRecordService;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 优惠券使用记录表 前端控制器
 * </p>
 *
 * @author 烟台业达-王世玺
 * @since 2021-10-11
 */
@Api(tags = "消费券记录列表", description = "消费券记录列表")
@RestController
@RequestMapping("/v1/consumer")
public class CouponUsageRecordController {


    @Autowired
    private CouponUsageRecordService couponUsageRecordService;
    
    
    @ApiOperation("消费券记录")
    @PostMapping("record")
    public Result<List<WechatDateRecordResponse>> consumptionRecordList(@RequestBody WechatRecordRequest wechatRecordRequest){
        List<WechatDateRecordResponse> wechatDateRecordResponses =
                couponUsageRecordService.consumptionRecordList(wechatRecordRequest, AuthUtil.getUserInfo().getShopId());
        return Result.buildSuccess(wechatDateRecordResponses);

    }
    @ApiOperation("消费券记录详情")
    @GetMapping("record/{usageRecordId}")
    public Result<CouponUsageRecord> getCouponUsageRecord(@PathVariable("usageRecordId") String usageRecordId){
        CouponUsageRecord couponUsageRecord = couponUsageRecordService.getCouponUsageRecord(usageRecordId);
        return Result.buildSuccess(couponUsageRecord);
    }




}

